<template>
  <div>
      <h2>会员权益修改</h2>
      <table class="table table-bordered">
        <tbody>
          <tr>
            <td align="right">权益标题</td>
            <td><input type="text" v-model="state.RightName"></td>
          </tr>
          <tr>
            <td></td>
            <td><input type="button" value="修改" @click="ok"></td>
          </tr>
        </tbody>
      </table>
  </div>
</template>

<script setup lang="ts">


import { reactive,toRefs,onMounted } from 'vue';
import axios from 'axios';
import { useRouter,useRoute } from 'vue-router'; 
const router = useRouter();
const route=useRoute();

onMounted (()=>{
  ftlist();
})

let data:any=reactive({
    state:{
      RightName:''
    }
   
  });
  let {state} =toRefs(data);

  const ftlist=()=>{
    
    let obj={
      RightId:route.query.RightId,
    }
    axios({
      url:'/api/one/Rightft/Rightft',
      method:'get',
      params:obj
    })
    .then((res)=>{
      console.log(res);
      state.value=res.data.data;
    })
    .catch((err)=>{
      console.log(err);
    })
  

  }




const ok=()=>{
  if(state.value.RightName==''){
    alert('标题不能为空')
  }
  let obj={
    RightId:route.query.RightId,
    RightName:state.value.RightName,
  }
axios({
  url:'/api/one/RightUpdate/RightUpdate',
  method:'put',
  data:obj,
})
.then((res)=>{
  console.log(res);
  if(res.data.data==1){
      alert("成功")
      router.push('/main/memberRightList')
      
  }
  else{
    alert('失败')
    return;
  }
})

}



</script>

<style scoped>

</style>